package com.wrs.wrsfcmpush.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.util.Log;

public class AccessibilityServiceReceiver extends BroadcastReceiver {
    String actionSTr = "android.accessibilityservice.AccessibilityService";
    String tag = "保活 AccessibilityServiceReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(actionSTr)) {
            // 无障碍服务已开启
            Log.e(tag, "无障碍服务已经开启");
        }
//
//        else if (action.equals(Intent.ACTION_ACCESSIBILITY_SERVICE_DISABLED)) {
//            // 无障碍服务已关闭，需要重新开启
//            startAccessibilityService(context);
//        }
    }

    private void startAccessibilityService(Context context) {
        Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
        context.startActivity(intent);
    }
}